<template>
    <div>
        <h1>
            <ul class="mui-table-view" >
                <li class="mui-table-view-cell mui-media"  v-for="item in newlist" :key="item.id">
                    <router-link :to="'/home/newsinfo/'+item.id">
                        <img class="mui-media-object mui-pull-left" src="http://cdn.duitang.com/uploads/item/201205/06/20120506220122_YNMPX.thumb.224_0.jpeg">
                        <div class="mui-media-body">
                            <h1>{{item.title}}</h1>
                            <div class="mui-ellipsis">
                                <span>发表时间：{{item.time | dateFormat('YYYY-MM-DD')}}</span>
                                <span>点击次数：{{item.num}}</span>
                            </div>
                        </div>
                    </router-link>
                </li>
            </ul>
        </h1>
    </div>
</template>
<script>
    import { Toast } from 'mint-ui';
    export default {
        data(){
            return{
                newlist:[]
            }
        },
        created(){
          this.getnewlist();
        },
        methods:{
            getnewlist(){
                this.$http.jsonp('http://localhost:80/vue-cms/1.php/login')
                    .then(data=>{
                        if(data.status === 200){
                            //console.log(data.bodyText)
                            this.newlist = JSON.parse(data.bodyText);
                            //注意这个返回的值仍然是一个字符串，这样子就会导致其实返回不了正确的结果，需要用JSON.parse对其进行一次处理，这样子就可以得到
                            //正确的JSON格式的字符串
                            //console.log(this.newlist);
                        }else {
                            Toast("加载数据失败")
                        }
                    })
            }
        }
    }
</script>
<style scoped>
.mui-table-view li h1 {
    font-size: 14px;
}
.mui-ellipsis {
    font-size: 12px;
    color: #226aff;
    display: flex;
    justify-content: space-between;

}
    /*display: flex;*/
    /*justify-content: space-between;*/
    /*这是css浮动的方式*/
</style>